# Main
#
# Proyecto Único - Versión 1.0
# Grupo R07:
# Cesar Hernández (06-39724)
# Daniel Valera (07-41725)

require "Lexer"
require "Token"

# Programa principal

tokens = []
errors = []

if ARGV[0] == "-e"
	lexer = Lexer.new(ARGV[1])
else
	archive = File.open(ARGV[0],"r")
	lexer = Lexer.new(archive)
end

token = lexer.yylex()

while token != nil
	begin
		tokens[tokens.length] = token
		token = lexer.yylex()
	rescue => error
		errors[errors.length] = error
	end
end

if errors.empty?
	tokens.each do |tokens|
		puts(tokens.to_s)
	end
else
	errors.each do |errors|
		puts(errors.to_s)
	end
end
